/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import {Form, Input, Radio, Select, InputNumber, DatePicker } from 'antd';
import {connect} from 'dva';
import moment from 'moment'
const FormItem = Form.Item;
const { TextArea } = Input;
const RadioGroup = Radio.Group;
const Option = Select.Option;
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }

  render() {
    const formItemLayoutWithLabel = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 7},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 15},
      }
    };

    const {getFieldDecorator} = this.props.form;
    return (
      <div>
        <Form onSubmit={this.handleSubmit}>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               测量速度
            </span>
            )}
          >
            {getFieldDecorator('measuring_speed', {
              initialValue: this.props.editRecord.config.measuring_speed?this.props.editRecord.config.measuring_speed.toString():'',
              rules: [{ required: true, message: '请输入测量速度' }],
            })(
              <Select>
                {
                  [{key:1,label:'1秒'},{key:2,label:'2秒'},{key:3,label:'3秒'}
                    ,{key:4,label:'4秒'},{key:5,label:'5秒'},{key:6,label:'6秒'},{key:7,label:'7秒'},{key:8,label:'8秒'},{key:9,label:'9秒'},{key:0,label:'20秒'}].map((item,index)=>{
                    return (
                      <Option key={item.key} value={item.key.toString()}>{item.label}</Option>
                    )
                  })
                }
              </Select>
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               上报频率
            </span>
            )}
          >
            {getFieldDecorator('report_frequency', {
              initialValue: this.props.editRecord.config.report_frequency?this.props.editRecord.config.report_frequency.toString():'',
              rules: [{ required: true, message: '请输入上报频率' }],
            })(
              <Select>
                {
                  [{key:1,label:'每天1次'},{key:2,label:'每天2次'},{key:3,label:'每天4次'},{key:4,label:'每3小时1次'}
                    ,{key:5,label:'每两小时1次'},{key:6,label:'每1小时1次'},{key:7,label:'每半小时1次'}].map((item,index)=>{
                    return (
                      <Option key={item.key} value={item.key.toString()}>{item.label}</Option>
                    )
                  })
                }
              </Select>

            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            help="引发上报的压力波动值，范围0-2.55"
            label={(
              <span>
               上报波动值(MPA)
            </span>
            )}
          >
            {getFieldDecorator('fluctuation_pressure_value', {
              initialValue: this.props.editRecord.config.fluctuation_pressure_value,
              rules: [{ required: true, message: '请输入上报频率' }],
            })(
              <InputNumber  min={0} max={2.55} style={{width:'100%'}}/>
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            help="范围0-99.99"
            label={(
              <span>
               上限压力值(MPA)
            </span>
            )}
          >
            {getFieldDecorator('upper_limit_pressure', {
              initialValue:  this.props.editRecord.config.upper_limit_pressure,
              rules: [{ required: true, message: '请输入上限压力值' }],
            })(
              <InputNumber  min={0} max={99.99} style={{width:'100%'}}/>
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            help="范围0-99.99"
            label={(
              <span>
               下限压力值(MPA)
            </span>
            )}
          >
            {getFieldDecorator('lower_limit_pressure', {
              initialValue:  this.props.editRecord.config.lower_limit_pressure,
              rules: [{ required: true, message: '请输入下限压力值' }],
            })(
              <InputNumber min={0} max={99.99} style={{width:'100%'}}/>
            )}
          </FormItem>
        </Form>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);


